//232.用栈实现队列
//https://leetcode.cn/problems/implement-queue-using-stacks/?envType=daily-question&envId=2024-03-04
class MyQueue {
    stack<int> st1; //入队顺序
    stack<int> st2; //出队顺序

    int top()
    {
        while(!st1.empty())
        {
            st2.push(st1.top());
            st1.pop();
        }
        return st2.top();
    }
public:
    MyQueue() {}
    
    void push(int x) {
        while(!st2.empty())
        {
            st1.push(st2.top());
            st2.pop();
        }
        st1.push(x);
    }
    
    int pop() {
        int ret = top();
        st2.pop();
        return ret;
    }
    
    int peek() {
        return top();
    }
    
    bool empty() {
        return st1.empty() && st2.empty();
    }
};